<?php

namespace App\Providers;

use EasyWeChat\Foundation\Application;


class PayServiceProvider extends AbstractServiceProvider
{
    /**
     * The Service name.
     * @var string
     */
    protected $serviceName = 'pay';

    /**
     * Register application service.
     *
     * @return void
     */
    public function register()
    {
        $this->di->setShared(
			$this->serviceName,
			function () {
                $config = $this->getShared('config')->pay->weixin;
                $options = [
                    'app_id' => $config->app_id,
                    'payment' => [
                        'merchant_id'        => $config->merchant_id,
                        'key'                => $config->key,
                        //'cert_path'          => 'cert/client-cert.pem',
                        //'key_path'           => 'cert/client-key.pem',
                        //'notify_url'         => 'http://'. $this->getShared('request')->getServerName() . '/common/paynotify',
                        'notify_url'         => 'http://h5.15miwo.cn/notify',
                    ],
                ];

                $app = new Application($options);
				return $app;
			}
		);
    }
}
